<%@page import="java.util.ArrayList"%>
<%@page import="telefonia.entity.Pais"%>
<%@page import="telefonia.dao.DaoPais"%>
<!-- Rescate de variables formulario -->

<%
    String codigo = "";
    String descripcion = "";

    ArrayList<Pais> paises = new ArrayList<Pais>();

    if (request.getParameter("txtCodigo") != null) {
        codigo = request.getParameter("txtCodigo");
        descripcion = request.getParameter("txtDescripcion");
    }

%>

<!--Controlador
<%
    if (request.getParameter("btnLeer") != null) {
       
        paises.add(DaoPais.sqlRead(new Pais(codigo)));
    }
    if (request.getParameter("btnGuardar") != null) {
        DaoPais.sqlInsert(new Pais(codigo, descripcion));
    }
    if (request.getParameter("btnActualizar") != null) {
    }
    if (request.getParameter("btnEliminar") != null) {
        DaoPais.sqlDelete(new Pais(codigo));
    }
    if (request.getParameter("btnCancelar") != null) {
    }

%>
-->

<%-- 
    Document   : FrPais
    Created on : 07-10-2013, 10:19:17 AM
    Author     : Duoc
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Pais</title>
    </head>
    <body>
        <form method="GET">
            <table border="0">
                <thead>
                    <tr>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Codigo</td>
                        <td><input type="text" name="txtCodigo" value="<% out.write(codigo);%>" size="10" /></td>
                        <td><input type="submit" id="btnBus" name="btnBus" value="?"/></td>
                        <td><input type="submit" name="btnLeer" id="btnLeer" value="Leer"/></td>
                        <td><input type="submit" value="btnSalir" value="Salir" /></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Descripcion</td>
                        <td><input type="text" name="txtDescripcion" value="<% out.write(descripcion);%>" /></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><input type="submit" value="Guardar" name="btnGuardar" id="btnGuardar"/></td>
                        <td><input type="submit" value="Eliminar" name="btnEliminar" id="btnEliminar"/></td>
                        <td><input type="submit" value="Actualizar" name="btnActualizar" id="btnActualizar"/></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                </tbody>
            </table>

            <table>
                <tr>
                    <th>ID</th>
                    <th>Descripcion</th>
                </tr>
                <%
                    if (paises.size()>0) {


                        for (Pais pais : paises) {
                            
                            out.write("<tr>");
                            out.write("<td>");
                            out.write(pais.getCodigo());
                            out.write("</td>");
                            out.write("<td>");
                            out.write(pais.getDescripcion());
                            out.write("</td>");
                            out.write("</tr>");
                        }

                    }
                    
                %>


            </table>
        </form>
    </body>
</html>
